basically try to enforce the windows compatibility as guess from server
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 12 Feb 2025 22:02:57 +0000 (23:02 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 19 Feb 2025 13:12:37 +0000 (13:12 +0000)
for now simple rule to guess if the server has windows naming enforced

if windows naming is enforced, we enforce it for new files

if not, we do not care

for now limited to spaces removal

more to come

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/discovery.cpp

index 646808147e3b1e3d735fb423da7371294fb4c79f..aa669681057a0e534d4db55f58d7e5462eac3c4e 100644 (file)
@@ -290,7 +290,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
     const auto hasLeadingOrTrailingSpaces = excluded == CSYNC_FILE_EXCLUDE_LEADING_SPACE
                                             || excluded == CSYNC_FILE_EXCLUDE_TRAILING_SPACE
                                             || excluded == CSYNC_FILE_EXCLUDE_LEADING_AND_TRAILING_SPACE;
-    const auto leadingAndTrailingSpacesFilesAllowed = _discoveryData->_leadingAndTrailingSpacesFilesAllowed.contains(_discoveryData->_localDir + path);
+    const auto leadingAndTrailingSpacesFilesAllowed = !_discoveryData->_shouldEnforceWindowsFileNameCompatibility || _discoveryData->_leadingAndTrailingSpacesFilesAllowed.contains(_discoveryData->_localDir + path);
     if (hasLeadingOrTrailingSpaces && (wasSyncedAlready || leadingAndTrailingSpacesFilesAllowed)) {
         excluded = CSYNC_NOT_EXCLUDED;
     }
@@ -470,6 +470,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
             }
             item->_errorString = reasonString.isEmpty() ? errorString : QStringLiteral("%1 %2").arg(errorString, reasonString);
             item->_status = SyncFileItem::FileNameInvalidOnServer;
+            maybeRenameForWindowsCompatibility(_discoveryData->_localDir + item->_file, excluded);
             break;
         }
     }